home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / linux / tools / amiga / gzip-1.1.2.lha / gzip-1.1.2 / sub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-28  |  768 b   |  29 lines

  1. /* sub.c -- simple filter for 8 bit images or any 8 bit "smooth" data
  2.  * Written by Arthur David Olson <ado@elsie.nci.nih.gov>
  3.  *
  4.  * sub can improve compression of 8 bit images or any 8 bit "smooth" data.
  5.  * It simply emits on stdout the differences between successive bytes
  6.  * read from stdin. For compression, use:
  7.  *   sub < raw_data | gzip > data.sub.gz
  8.  * For decompression, use:
  9.  *   gunzip < data.sub.gz | add > raw_data
  10.  *
  11.  * This program can easily be extended to handle 24 bit images, or
  12.  * sequences of slowly varying floating point numbers.
  13.  */
  14.  
  15. #include "stdio.h"
  16.  
  17. main()
  18. {
  19.     int    c;
  20.     int    prevc = 0;
  21.  
  22.     while ((c = getchar()) != EOF) {
  23.     (void) putchar((c - prevc) & 0xff);
  24.     prevc = c;
  25.     }
  26.     exit(0);
  27.     return 0; /* just to avoid warnings */
  28. }
  29.